package com.hb.task.runner;

import java.util.Calendar;

import org.quartz.JobDetail;
import org.quartz.Scheduler;
import org.quartz.SchedulerException;
import org.quartz.SchedulerFactory;
import org.quartz.SimpleTrigger;
import org.quartz.impl.StdSchedulerFactory;

import com.hb.task.job.SendMsgJob;

public class SendMsgRunner {
	
	public static void init() {
		SendMsgRunner smr = new SendMsgRunner();
		try {
			smr.task();
		} catch (SchedulerException e) {
			e.printStackTrace();
		}
	}
	
	public void task() throws SchedulerException {
		SchedulerFactory schedulerFactory = new StdSchedulerFactory();
		Scheduler scheduler = schedulerFactory.getScheduler();

		JobDetail jobDetail = new JobDetail("SendMsg", "SendMsgGroup", SendMsgJob.class);
		
		SimpleTrigger simpleTrigger = new SimpleTrigger("simpleTrigger", "triggerGroup-s1");
		
		simpleTrigger.setStartTime(Calendar.getInstance().getTime());
		simpleTrigger.setRepeatInterval(24 * 60 * 60 * 1000);
		simpleTrigger.setRepeatCount(simpleTrigger.REPEAT_INDEFINITELY);
		
		scheduler.scheduleJob(jobDetail, simpleTrigger);

		scheduler.start();
	}
	
}
